
package com.monlyu.action.home;

import com.monlyu.action.PageAction;
import com.monlyu.bo.HomeBo;
import com.monlyu.bo.model.HomeModel;
import com.monlyu.util.JsonUtil;
import com.monlyu.vo.Education;

/**
 * @author monlyu
 * @since 2009-12-15
 */
public class HomeAction extends PageAction {

    private HomeBo homeBo;

    private HomeModel model;

    private String messages;

    private boolean home = true;

    public boolean isHome(){
        return home;
    }

    public String getMessages(){
        return messages;
    }

    public HomeModel getModel(){
        return model;
    }

    public void setHomeBo(HomeBo homeBo){
        this.homeBo = homeBo;
    }

    @Override
    public String execute(){
        model = homeBo.buildHomeModel(getDefPage());
        messages = "";
        Education e = homeBo.get(Education.class, 1l);
        if (e != null) {
            messages = e.getContent();
        }
        return view("home.jsp");
    }

    public String listNoties(){
        return ajax(JsonUtil.obj2Json(homeBo.getLatestNotices()));
    }

    public String print(){
        return "";
    }
}
